﻿using EnvDTE;

namespace PropertyAddin
{
	class ConstructorParameter
	{
		#region Private Members
		private string m_Name;
		private CodeTypeRef m_Type;
		private string m_FieldName;
		#endregion Private Members

		#region Constructors
		/// <summary>
		/// Creates a constructor parameter with that class field instance (the associated field name is
		/// set).
		/// </summary>
		/// <param name="cf"></param>
		public ConstructorParameter(ClassField cf)
		{
			m_Name = cf.ParameterName;
			m_Type = cf.Variable.Type;
			m_FieldName = cf.Name;
		}

		/// <summary>
		/// Creates a constructor parameter with that code element (must be a code parameter instance).
		/// The associated field name is empty.
		/// </summary>
		/// <param name="element"></param>
		public ConstructorParameter(CodeElement element)
		{
			CodeParameter parameter = element as CodeParameter;

			m_Name = element.Name;
			m_Type = parameter.Type;
			m_FieldName = string.Empty;
		}
		#endregion Constructors

		#region Public Attributes
		/// <summary>
		/// Gets the name.
		/// </summary>
		public string Name
		{
			get { return m_Name; }
		}

		/// <summary>
		/// Gets the type.
		/// </summary>
		public CodeTypeRef Type
		{
			get { return m_Type; }
		}

		/// <summary>
		/// Gets the name of the field associated to the parameter.
		/// </summary>
		public string FieldName
		{
			get { return m_FieldName; }
		}
		#endregion Public Attributes
	}
}
